using NHibernate;
using NHibernate.Cfg;

using log4net;

namespace Server
{
    class Database
    {
        private static ISessionFactory factory;

        // Retrieve factory
        public static ISessionFactory Factory
        {
            get
            {
                if (factory == null)
                {
                    // Configure log4net
                    log4net.Config.XmlConfigurator.Configure();

                    // Configure hibernate
                    Configuration cfg = new Configuration().Configure("Database.cfg.xml");

                    // Build factory
                    factory = cfg.BuildSessionFactory();
                }

                // Return factory
                return factory;
            }
        }
    }
}
